package com.xjprojectc.business.service.impl;

import java.util.List;

import com.tech.framework.service.impl.BaseServiceImpl;
import com.xjprojectc.business.pojo.T_regionalism;
import com.xjprojectc.business.service.RegionalismService;

@SuppressWarnings("unchecked")
public class RegionalismServiceImpl extends BaseServiceImpl implements RegionalismService{
	
	public List<T_regionalism> getRegionalismPager(T_regionalism regionalism) {
		return find(T_regionalism.class.getName()+".selectPaged", regionalism);
	}
	
	public List<T_regionalism> getRegionalismList(T_regionalism regionalism) {
		return find(T_regionalism.class.getName()+".select", regionalism);
	}

	public T_regionalism getOneRegionalism(String id) {
		return (T_regionalism) find(T_regionalism.class.getName()+".getOneById",id).get(0);
	}

	public int getPageCount(T_regionalism managerinfo) {
		return Integer.parseInt(find(T_regionalism.class.getName()+".selectCount",managerinfo).get(0).toString());
	}
	
	@SuppressWarnings("unchecked")
	public boolean addRegionalism(T_regionalism regionalism) {
		boolean bool = false;
		try {
			insert(regionalism);
			bool = true;
		} catch (Exception e) {
		}
		return bool;
	}
	
	public List<T_regionalism> getRegionalismListBySupserId(String id) {
		return find(T_regionalism.class.getName()+".selectBySupserId", id);
	}
	

	public boolean delRegionalism(T_regionalism regionalism) {
		boolean bool = false;
		try {
			T_regionalism r = this.getOneRegionalism(regionalism.getId().toString());
			if(r.getLevelnum() != null){
				if(r.getLevelnum() == 1){
					List<T_regionalism> list = this.getRegionalismListBySupserId(r.getId().toString());
					for(T_regionalism t : list){
						List<T_regionalism> list2 = this.getRegionalismListBySupserId(t.getId().toString());
						for(T_regionalism tt : list2){
							remove(tt);
						}
						remove(t);
					}
					remove(regionalism);
				}
				if(r.getLevelnum() == 2){
					List<T_regionalism> list = this.getRegionalismListBySupserId(regionalism.getId().toString());
					for(T_regionalism t : list){
						remove(t);
					}
					remove(regionalism);
				}
				if(r.getLevelnum() == 3){
					remove(regionalism);
				}
				remove(regionalism);
			}
			remove(regionalism);
			bool = true;
		} catch (Exception e) {
		}
		return bool;
	}


	public boolean updateRegionalism(T_regionalism regionalism) {
		boolean bool = false;
		try {
			update(regionalism);
			bool = true;
		} catch (Exception e) {
		}
		return bool;
	}
	
	

	
}
